home *** CD-ROM | disk | FTP | other *** search
/ Creating Your Own America Online Web Pages / Creating Your Own America Online Web Pages.iso / TOOLS / TEX2RTF / SOURCES.ZIP / SRC / WXWIN / WX_UTILS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-05  |  4.8 KB  |  163 lines

  1. /*
  2.  * File:     wx_utils.h
  3.  * Purpose:  Miscellaneous utilities
  4.  *
  5.  *                       wxWindows 1.50
  6.  * Copyright (c) 1993 Artificial Intelligence Applications Institute,
  7.  *                   The University of Edinburgh
  8.  *
  9.  *                     Author: Julian Smart
  10.  *                       Date: 7-9-93
  11.  *
  12.  * Permission to use, copy, modify, and distribute this software and its
  13.  * documentation for any purpose is hereby granted without fee, provided
  14.  * that the above copyright notice, author statement and this permission
  15.  * notice appear in all copies of this software and related documentation.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
  18.  * IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
  19.  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
  22.  * UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
  23.  * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
  24.  * LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
  25.  * DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
  26.  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27.  */
  28.  
  29. #ifndef wxb_utilsh
  30. #define wxb_utilsh
  31. #include "wx_obj.h"
  32. #include "wx_list.h"
  33.  
  34. #ifdef wx_x
  35. #include <dirent.h>
  36. #include <unistd.h>
  37. #endif
  38.  
  39. // sprintf is often needed, but we don't always want to include the whole
  40. // of stdio.h!
  41. #if (defined(wx_msw) || defined(wx_dos))
  42. extern "C" int __cdecl sprintf(char *, const char *, ...);
  43. #endif
  44. #ifdef wx_x
  45. #include <stdio.h>
  46. #endif
  47.  
  48. // Make a copy of this string using 'new'
  49. char *copystring(char *s);
  50.  
  51. // Generate a unique ID
  52. long NewId(void);
  53.  
  54. // Ensure subsequent IDs don't clash with this one
  55. void RegisterId(long id);
  56.  
  57. // Useful buffer
  58. extern char wxBuffer[];
  59.  
  60. // Various conversions
  61. void StringToFloat(char *s, float *number);
  62. char *FloatToString(float number);
  63. void StringToDouble(char *s, double *number);
  64. char *DoubleToString(double number);
  65. void StringToInt(char *s, int *number);
  66. void StringToLong(char *s, long *number);
  67. char *IntToString(int number);
  68. char *LongToString(long number);
  69.  
  70. // Matches string one within string two regardless of case
  71. #ifndef IN_CPROTO
  72. Bool StringMatch(char *one, char *two, Bool subString = TRUE, Bool exact = FALSE);
  73. #endif
  74.  
  75. // Some file utilities
  76.  
  77. #ifdef IN_CPROTO
  78. typedef       void    *wxPathList ;
  79. typedef       void    *wxLogClass;
  80. #else
  81. // Path searching
  82. class wxPathList: public wxList
  83. {
  84.   public:
  85.  
  86.   void AddEnvList(char *envVariable);    // Adds all paths in environment variable
  87.   void Add(char *path);
  88.   char *FindValidPath(char *filename);   // Find the first full path
  89.                                          // for which the file exists
  90.   void EnsureFileAccessible(char *path); // Given full path and filename,
  91.                                          // add path to list
  92.   Bool Member(char *path);
  93. };
  94.  
  95. Bool FileExists(char *filename);
  96. Bool IsAbsolutePath(char *filename);
  97.  
  98. // Get filename
  99. char *FileNameFromPath(char *path);
  100.  
  101. // Get directory
  102. char *PathOnly(char *path);
  103.  
  104. void Dos2UnixFilename(char *s);
  105. void Unix2DosFilename(char *s);
  106.  
  107. // Get a temporary filename, opening and closing the file.
  108. // void wxGetTempFileName(char *prefix, char *buf);
  109.  
  110. // Does the pattern contain wildcards?
  111. Bool wxIsWild(char *pattern);
  112.  
  113. // Does the pattern match the text (usually a filename)?
  114. // If dot_special is TRUE, doesn't match * against . (eliminating
  115. // `hidden' dot files)
  116. Bool wxMatchWild(char *pattern, char *text, Bool dot_special = TRUE);
  117.  
  118. // Execute another program. Returns FALSE if there was an error.
  119. // Bool wxExecute(char *command);
  120.  
  121. // Concatenate two files to form third
  122. Bool wxConcatFiles(char *file1, char *file2, char *file3);
  123.  
  124. // Copy file1 to file2
  125. Bool wxCopyFile(char *file1, char *file2);
  126.  
  127. // Remove file
  128. Bool wxRemoveFile(char *file);
  129.  
  130. // Rename file
  131. Bool wxRenameFile(char *file1, char *file2);
  132.  
  133. // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
  134. // long wxGetFreeMemory(void);
  135.  
  136. #ifndef max
  137. // inline int max(int a, int b) { return a > b ? a : b; }
  138. #define max(a,b)            (((a) > (b)) ? (a) : (b))
  139. #endif
  140. #ifndef min
  141. // inline int max(int a, int b) { return a < b ? a : b; }
  142. #define min(a,b)            (((a) < (b)) ? (a) : (b))
  143. #endif
  144.  
  145. inline void wxYield(void) {}
  146.  
  147. // void wxDebugMsg(char *fmt ...) ;
  148. // void wxBell(void) ;
  149.  
  150. /*
  151.  * Error message functions used by wxWindows
  152.  *
  153.  */
  154.  
  155. // Non-fatal error (continues) 
  156. void wxError(char *msg, char *title = "wxWindows Internal Error");
  157.  
  158. // Fatal error (exits)
  159. void wxFatalError(char *msg, char *title = "wxWindows Fatal Error");
  160.  
  161. #endif // IN_CPROTO
  162. #endif // wxb_utilsh
  163.